home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-valuns.ads < prev    next >
Text File  |  1996-01-30  |  4KB  |  71 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --                       S Y S T E M . V A L _ U N S                        --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.6 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with System.Unsigned_Types;
  27.  
  28. package System.Val_Uns is
  29. pragma Pure (Val_Uns);
  30.  
  31.    function Scan_Unsigned
  32.      (Str  : String;
  33.       Ptr  : access Positive'Base;
  34.       Max  : Positive'Base)
  35.       return System.Unsigned_Types.Unsigned;
  36.    --  This function scans the string starting at Str (Ptr.all) for a valid
  37.    --  integer according to the syntax described in (RM 3.5(43)). The substring
  38.    --  scanned extends no further than Str (Max). There are three cases for the
  39.    --  return:
  40.    --
  41.    --  If a valid integer is found after scanning past any initial spaces, then
  42.    --  Ptr.all is updated past the last character of the integer (but trailing
  43.    --  spaces are not scanned out).
  44.    --
  45.    --  If no valid integer is found, then Ptr.all points either to an initial
  46.    --  non-digit character, or to Max + 1 if the field is all spaces and the
  47.    --  exception Constraint_Error is raised.
  48.    --
  49.    --  If a syntactically valid integer is scanned, but the value is out of
  50.    --  range, or, in the based case, the base value is out of range or there
  51.    --  is an out of range digit, then Ptr.all points past the integer, and
  52.    --  Constraint_Error is raised. Note that if a minus sign is present, and
  53.    --  the integer value is non-zero, then constraint error will be raised.
  54.    --
  55.    --  Note: these rules correspond to the requirements for leaving the pointer
  56.    --  positioned in Text_Io.Get
  57.    --
  58.    --  Note: if Str is null, i.e. if Max is less than Ptr, then this is a
  59.    --  special case of an all-blank string, and Ptr is unchanged, and hence
  60.    --  is greater than Max as required in this case.
  61.  
  62.    function Value_Unsigned
  63.      (Str : String)
  64.      return System.Unsigned_Types.Unsigned;
  65.    --  Used in computing X'Value (Str) where X is a modular integer type whose
  66.    --  modulus does not exceed the range of System.Unsigned_Types.Unsigned. Str
  67.    --  is the string argument of the attribute. Constraint_Error is raised if
  68.    --  the string is malformed, or if the value is out of range.
  69.  
  70. end System.Val_Uns;
  71.